package sizeyunsuan;

/**
 * Created by 春旺 on 2017/5/11.
 */
import java.io.IOException;
import java.util.*;
import java.io.*;
public class OutRandom {
    public static void main(String[] args)

     throws IOException
    {
        FileWriter fm = new FileWriter("problem.txt");
        BufferedWriter bufm = new BufferedWriter(fm);
        //确定输出的式子的个数。
        Scanner scan = new Scanner(System.in);
        System.out.println("你想输出几个式子：");
        int num1 = scan.nextInt();
        //确定几个数字参加运算
        System.out.println("你想要几个数字参加运算;");
        int num2 = scan.nextInt();
        //输出式子
        for (int i = 0; i < num1; i++) {
            for (int j = 0; j < num2; j++) {
                //产生20及其以内的数字
                Random a = new Random();
                int p = a.nextInt(21);
                System.out.print(p);
                bufm.write(p+" ");
                //产生运算符
                String peo[] = {"+", "-", "*", "/"};
                //最后一个数字之后没有运算符。

                int p2 = a.nextInt(2);
                //System.out.print(peo[p2]);

                //int p3 = a.nextInt(21);
                //System.out.print(p3);
                if (j < num2 - 1) {
                    System.out.print(peo[p2]);
                    bufm.write(peo[p2] + " ");
                }

            }
           // bufm.write("=" );
            bufm.newLine();
            bufm.flush();
            //System.out.println("=");
            System.out.println();


        }

    }

}
